home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / program / vbpxen.zip / VVDEMO.TXT < prev    next >
Text File  |  1991-10-07  |  5KB  |  125 lines

  1. Visual Basic / Paradox Engine Demo  
  2.  
  3. Written by Steve Jackson 
  4.            9152 Brabham Drive
  5.            Huntington Beach, CA 92646
  6.  
  7.            Source code free to all.
  8.  
  9. Comments, questions are welcome.  If you know of any
  10. ways I can earn a little extra income to purchase a
  11. faster computer (and with more memory of course) that
  12. would be welcome too.
  13.  
  14. ======================================================
  15. A Visual Basic application called "Visual Video" that
  16. uses Paradox Engine for database access.  It is NOT
  17. meant to be a viable video tape rental system - just a
  18. little sample of calling the Paradox Engine DLL from
  19. Windows VB.  No exe file is included to keep zip file
  20. small.  Also, the DLL files are not included.  
  21. ======================================================
  22.  
  23. Assumptions:   
  24.    You have a working knowledge of Paradox Engine
  25.    You have the Paradox Engine DLL - PXENGWIN.DLL 
  26.    You have Visual Basic and its DLL
  27.  
  28. Suggestion:    
  29.    Load this in a separate directory.
  30.    Put this name in db_dir in GLOBAL.BAS 
  31.    (so the app will know where tables are)
  32.  
  33. Files included:
  34.        VVDEMO.MAK          Project make file
  35.        PXMODULE.BAS        Engine DLL definitions
  36.                            and calls to engine functions
  37.        VVDBMOD.BAS         Customer database routines
  38.        VVDBMOD2.BAS        Item database routines
  39.        VVGLBL.BAS          Global defines - 
  40.                            but no engine stuff
  41.        *.FRM               Various forms
  42.        *.DB and *.PX       Customer and Item databases
  43.        VVDEMO.TXT          This file
  44.  
  45.  
  46. BACKGROUND
  47.  
  48. The Paradox Engine comes with a DLL library with all the
  49. engine functions except for PxNetInit() which is handled
  50. a little differently in Windows.  Visual Basic can use
  51. most of these easily (more on this in a moment) by
  52. defining them as DLL declarations.  The important thing
  53. is to define the C argument types in equivalent Visual
  54. Basic types, and it is VERY important to use ByVal
  55. properly to define variables passed by reference.  Also,
  56. strings passed to functions for update should be
  57. defined as fixed length (see PxGetAlpha).  C does not
  58. understand VB's variable length strings and will
  59. promptly crash your app if you get it wrong. 
  60.  
  61. Most of the engine functions return an int as an error
  62. code, and this works quite well in VB.  I called a
  63. generic error routine after most calls that traps show-
  64. stopper errors from normal expected errors like not-
  65. found, etc.   At least one of the functions returns a
  66. pointer to a string - PxErrMsg, and I have not yet
  67. worked out how to use that in VB so for right now my
  68. error routine just shows the error number.  Some sharp
  69. programmer could probably get some windows memory and
  70. grab a pointer to it, but those kind of API calls are
  71. beyond the scope of this little tutorial.  
  72.  
  73. STRUCTURE OF VVDEMO
  74.  
  75. I tried to put all the Paradox Engine declarations in
  76. one BAS file to isolate it from the rest of the app.  I
  77. also have one BAS file for each database with various
  78. functions for Startup, Get, Add, Update, Delete, etc.
  79. etc.  This results in a two layer approach:  The form
  80. objects call the generic functions in VVDBMODx.BAS which
  81. in turn call the Paradox specific functions in
  82. PXMODULE.BAS.  The reason for this is to make it easier
  83. to change the Paradox specific routines without affecting
  84. the application, and to keep your global file from
  85. getting cluttered up.  You may love it or hate it, but
  86. at least I had a reason for it! 
  87.  
  88. By the way, if you create module files as plain ASCII
  89. before editing them in VB, they will remain ASCII files
  90. that you can use with your favorite editor.  If you
  91. start a new module file in VB, it saves it in a weird
  92. tokenized form.  (After all, it is basic you know) 
  93.  
  94. NETWORK INIT
  95.  
  96. In the dos version, you can initialize to whatever kind
  97. of network you want with PxNetInit.  In windows, you
  98. must always init with PxWinInit, and it picks up the
  99. desired network from settings in WIN.INI.  I came up
  100. with a way to change this at run time in a C program
  101. like this:  I put up a dialog box with different network
  102. choices.  When the user clicks OK, I wrote to WIN.INI
  103. with the WriteProfileString() API call to change the
  104. settings, stopped the engine with PxExit(), and restarted
  105. with PxWinInit().  This picked up the network change (or
  106. userid or net drive) without stopping the app.  I have
  107. not tried it yet in VB, but it worked fine in C. 
  108.    
  109. FINAL WORDS
  110.  
  111. Thanks to my friend John Jaster who gave me most (but
  112. not all) of the Paradox DLL declarations.  I added some,
  113. and corrected a few.  They are still not complete, but I
  114. leave that to the next person in this chain.  Or if
  115. anyone reading this wants me to finish it up, let me
  116. know, and I'll find the time! 
  117.  
  118.    
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.